package com.ruoyi.match.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.match.domain.LeaderTeam;
import com.ruoyi.match.service.ILeaderTeamService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 队长队伍Controller
 * 
 * @author zhangrui
 * @date 2025-03-26
 */
@RestController
@RequestMapping("/match/LeaderTeam")
public class LeaderTeamController extends BaseController
{
    @Autowired
    private ILeaderTeamService leaderTeamService;

    /**
     * 查询队长队伍列表
     */
    @PreAuthorize("@ss.hasPermi('match:LeaderTeam:list')")
    @GetMapping("/list")
    public TableDataInfo list(LeaderTeam leaderTeam)
    {
        startPage();
        List<LeaderTeam> list = leaderTeamService.selectLeaderTeamList(leaderTeam);
        return getDataTable(list);
    }

    /**
     * 导出队长队伍列表
     */
    @PreAuthorize("@ss.hasPermi('match:LeaderTeam:export')")
    @Log(title = "队长队伍", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LeaderTeam leaderTeam)
    {
        List<LeaderTeam> list = leaderTeamService.selectLeaderTeamList(leaderTeam);
        ExcelUtil<LeaderTeam> util = new ExcelUtil<LeaderTeam>(LeaderTeam.class);
        util.exportExcel(response, list, "队长队伍数据");
    }

    /**
     * 获取队长队伍详细信息
     */
    @PreAuthorize("@ss.hasPermi('match:LeaderTeam:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(leaderTeamService.selectLeaderTeamByUserId(userId));
    }

    /**
     * 新增队长队伍
     */
    @PreAuthorize("@ss.hasPermi('match:LeaderTeam:add')")
    @Log(title = "队长队伍", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LeaderTeam leaderTeam)
    {
        return toAjax(leaderTeamService.insertLeaderTeam(leaderTeam));
    }

    /**
     * 修改队长队伍
     */
    @PreAuthorize("@ss.hasPermi('match:LeaderTeam:edit')")
    @Log(title = "队长队伍", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LeaderTeam leaderTeam)
    {
        return toAjax(leaderTeamService.updateLeaderTeam(leaderTeam));
    }

    /**
     * 删除队长队伍
     */
    @PreAuthorize("@ss.hasPermi('match:LeaderTeam:remove')")
    @Log(title = "队长队伍", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(leaderTeamService.deleteLeaderTeamByUserIds(userIds));
    }
}
